using Boo.Lang;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using UnityEngine;

[Serializable]
public class PartScroller : MonoBehaviour
{
	[Serializable]
	[CompilerGenerated]
	internal sealed class _0024DragObject_0024425 : GenericGenerator<object>
	{
		internal float _0024distance_0024431;

		internal PartScroller _0024self__0024432;

		public _0024DragObject_0024425(float distance, PartScroller self_)
		{
			_0024distance_0024431 = distance;
			_0024self__0024432 = self_;
		}

		public override IEnumerator<object> GetEnumerator()
		{
			return new _0024(_0024distance_0024431, _0024self__0024432);
		}
	}

	public float spring;

	public float damper;

	public float drag;

	public float angularDrag;

	public float distance;

	private SpringJoint springJoint;

	public Camera mainCamera;

	public PartScroller()
	{
		spring = 50f;
		damper = 5f;
		drag = 10f;
		angularDrag = 5f;
		distance = 0.2f;
	}

	public void Update()
	{
		if (!Input.GetMouseButtonDown(0))
		{
			return;
		}
		RaycastHit hitInfo = default(RaycastHit);
		if (Physics.Raycast(mainCamera.ScreenPointToRay(UnityEngine.Input.mousePosition), out hitInfo, 100f) && (bool)hitInfo.rigidbody && !hitInfo.rigidbody.isKinematic && !hitInfo.rigidbody.useGravity)
		{
			if (!springJoint)
			{
				GameObject gameObject = new GameObject("Rigidbody dragger");
				Rigidbody rigidbody = gameObject.AddComponent<Rigidbody>() as Rigidbody;
				springJoint = (gameObject.AddComponent<SpringJoint>() as SpringJoint);
				rigidbody.isKinematic = true;
			}
			springJoint.transform.position = hitInfo.point;
			springJoint.anchor = Vector3.zero;
			springJoint.spring = spring;
			springJoint.damper = damper;
			springJoint.maxDistance = distance;
			springJoint.connectedBody = hitInfo.rigidbody;
			StartCoroutine("DragObject", hitInfo.distance);
		}
	}

	public IEnumerator DragObject(float distance)
	{
		return new _0024DragObject_0024425(distance, this).GetEnumerator();
	}

	public void Main()
	{
	}
}
